//
//  ScenicMainTableViewCell.m
//  小胖兔旅行指南
//
//  Created by KANGEL on 15/4/13.
//  Copyright (c) 2015年 小胖兔. All rights reserved.
//

#import "ScenicMainTableViewCell.h"

@implementation ScenicMainTableViewCell

- (void)dealloc
{
    [_photoBackground release];
    [_sightAddress release];
    [_sightName release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //cell背景图view
        self.selectionStyle = UITableViewCellSelectionStyleNone;//选中的cell上效果种类，此为cell的视图上效果不响应，但是点击效果仍旧相应，解决点击cell时，自定义的view阴影消失取消。
        _photoBackground = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, 200)];
        [self.contentView addSubview:_photoBackground];
        //景点名、地点阴影view
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake([[UIScreen mainScreen] bounds].size.width / 8, 50, [[UIScreen mainScreen] bounds].size.width * 6 / 8, 100)];
        [view setBackgroundColor:[UIColor darkGrayColor]];
        [view setAlpha:0.7];
        [self.contentView addSubview:view];
//        [view setUserInteractionEnabled:NO];//view是否接受事件
        //景点名label
        _sightName = [[UILabel alloc] initWithFrame:CGRectMake(0, 15, view.frame.size.width, 50)];
        [view addSubview:_sightName];
        
        //固定定位图标view
        UIImage *addImage = [UIImage imageNamed:@"dingwei.png"];
        UIImageView *imageAdd = [[UIImageView alloc] initWithFrame:CGRectMake(view.frame.size.width / 8, 65, 20, 20)];
        [imageAdd setImage:addImage];
        [view addSubview:imageAdd];
        
        //景点地点view
        _sightAddress = [[UILabel alloc] init];
        NSMutableDictionary *dic = [NSMutableDictionary dictionary];
        [dic setObject:[UIFont systemFontOfSize:10] forKey:NSFontAttributeName];//字体大小
        //自定义字体数收缩
//        CGRect rect = [_sightAddress.text boundingRectWithSize:CGSizeMake(view.frame.size.width - 20, 20) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
        
        _sightAddress.frame = CGRectMake(view.frame.size.width / 8 + 20, 65, view.frame.size.width * 6 / 8 - 20, 20);
        [view addSubview:_sightAddress];
        
        
        
    }
    return self;
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
